<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
<h:head>
	<title>posterminals</title>
</h:head>
<h:body>
	<div align="center">
	<h1>Исправлено!</h1>

		<fieldset>
			<legend>Работа с постерминалами</legend>
	  			<h:form>
	  				<table border="0">
	  					<tr>
						    <td>ID:</td>
						    <td> 
						    <h:inputText value="#{tables.posId}"
						          required="true"
						          requiredMessage="You must enter an ID"
						          converterMessage="ID must be a number"
						          id="ID"/>
						    </td>
						    <td><h:message id="idCheck" for="ID" styleClass="error"/></td></tr>
						<tr>
						    <td>Address name:</td> 
						    <td>
						    <h:inputText value="#{tables.addressName}" 
						          required="true" 
						          requiredMessage="You must enter a address"
						          validatorMessage="Address must be at least 3 chars"
						          id="address">
						      <f:validateLength minimum="3"/>
						    </h:inputText></td>
						    <td><h:message id = "addressCheck" for="address" styleClass="error"/></td></tr>
					</table>
		  	  				
		  	  		<h:commandButton value="добавить" 
		               				 action="#{tables.addPosterminal}">
		              	<f:ajax execute="ID address"
		              	        render="posterminalTable textOut idCheck addressCheck"/> 
		  			</h:commandButton>  
	   				<br/>
					Posterminal number: <h:outputText value="#{tables.posCount}"
	  		        	          id="textOut"></h:outputText> <br/>
	
					<h:dataTable var="posterminal" 
	    	                     value="#{tables.posterminals}"
	        	                 border="1"
	           	                 id="posterminalTable">
	  					<h:column>
	  						<f:facet name="header">ID</f:facet>
	  						<h:outputText value="#{posterminal.id}" rendered = "#{!posterminal.editable}"></h:outputText>
	  						<h:inputText value="#{posterminal.id}" 
	  									 rendered = "#{posterminal.editable}"
	  									 required="true"
						          		 requiredMessage="You must enter an ID"
						          		 converterMessage="ID must be a number"
						          		 id="IDtable"></h:inputText>
						          		 <h:message id="idCheck" for="IDtable" styleClass="error"/>
    					</h:column>
	  					<h:column>
	  						<f:facet name="header">Address</f:facet>
	  						<h:outputText value="#{posterminal.address}" rendered = "#{!posterminal.editable}"></h:outputText>
	  						<h:inputText value="#{posterminal.address}" rendered = "#{posterminal.editable}"></h:inputText>
	  					</h:column>
	  					<h:column>
     						<f:facet name="header">Action</f:facet>
     						<h:commandButton value="Edit" action="#{tables.editAction(posterminal)}" 
                                       rendered="#{not posterminal.editable}">
                            	<f:ajax render="@form"/>
                            </h:commandButton>
     	     			</h:column>
					</h:dataTable>
					<h:commandButton value="Save Changes" action="#{tables.safeAction}">
						<f:ajax execute="posterminalTable"
							render="posterminalTable"/>
					</h:commandButton>
	 			</h:form>
		</fieldset>

	</div>

</h:body>

</html>